<form id="setting-form" class="form-horizontal" action="/admin/setting/host" method="post" accept-charset="utf-8">
    {% raw xsrf_form_html() %}
    <div class="form-group">
        <label for="project" class="col-md-2 col-lg-1 control-label">所属项目:</label>
        <div class="col-md-3 col-lg-2">
            <select id="project" name="project" class="form-control">
                <option value="0" selected>应用于所有项目</option>
                {% for pj in project_list %}
                <option value="{{ pj.id }}">{{ pj.name }}</option>
                {% end %}
            </select>
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 col-lg-1 control-label" for="host">Host:</label>
        <div class="col-md-3 col-lg-2">
            <input id="host" name="host" type="text" class="form-control" placeholder="www.bstester.com">
        </div>
    </div>
    <div class="form-group">
        <label for="ip" class="col-md-2 col-lg-1 control-label">IP:</label>
        <div class="col-md-3 col-lg-2">
            <input type="text" id="ip" name="ip" class="form-control" placeholder="192.168.1.1">
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-2 col-lg-1 control-label" for="db-ip">DB IP:</label>
        <div class="col-md-3 col-lg-2">
            <input id="db-ip" name="db-ip" type="text" class="form-control" placeholder="192.168.1.1">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-2 col-lg-offset-1 col-lg-1">
            <input type="button" id="submit" value="保存" class="btn btn-primary">
        </div>
    </div>
    <div class="form-group">
        <div class="col-md-offset-2 col-md-2 col-lg-offset-1 col-lg-1">
            <span class="label label-info sr-only" style="font-size:14px;" id="msg"></span>
        </div>
    </div>
</form>
<div class="table-responsive">
    <table class="table table-striped table-hover">
        <thead>
        <tr>
            <th>#</th>
            <th class="col-lg-2">
                <select id="setting-list" data-op="{{ op }}">
                    <option value="0">所属项目</option>
                    {% for pj in project_list %}
                        {% if pid == pj.id %}
                        <option value="{{ pj.id }}" selected>{{ pj.name }}</option>
                        {% else %}
                        <option value="{{ pj.id }}">{{ pj.name }}</option>
                        {% end %}
                    {% end %}
                </select>
            </th>
            <th>Host</th>
            <th>IP</th>
            <th>DB IP</th>
            <th>状态</th>
            <th class="col-lg-2">操作</th>
        </tr>
        </thead>
        <tbody>
        {% for i in range(len(lists)) %}
        <tr>
            <td>{{ (page-1)*limit+i+1 }}</td>
            <td>{{ lists[i].project_name }}</td>
            <td>{{ lists[i].name }}</td>
            <td>{{ lists[i].ip }}</td>
            <td>{{ lists[i].db_ip }}</td>
            <td>
                {% if lists[i].status == 1 %}
                <span class="label label-primary">启用中</span>
                {% else %}
                <span class="label label-warning">已禁用</span>
                {% end %}
            </td>
            <td>
                {% if lists[i].status == 1 %}
                <a class="btn btn-danger btn-enable-set" data-host="{{ lists[i].name }}" data-sid="{{ lists[i].id }}" data-pid="{{ lists[i].project_id }}" data-status="0">禁用</a>
                {% else %}
                <a class="btn btn-info btn-enable-set" data-host="{{ lists[i].name }}" data-sid="{{ lists[i].id }}" data-pid="{{ lists[i].project_id }}" data-status="1">启用</a>
                {% end %}&nbsp;&nbsp;
                {% if current_user.role != 2 %}
                <a class="btn btn-danger btn-delete" data-id="{{ lists[i].id }}">删除</a>
                {% end %}
            </td>
        </tr>
        {% end %}
        </tbody>
    </table>
    {% module nav(total_page, page, limit, '/admin/setting/host/{}'.format(pid)) %}
</div>